<?php


namespace coco\exception;


use coco\Exception;
use coco\Response;
use Throwable;

class HttpResponseException extends Exception
{
    private $data;
    private $response_type;

    public function __construct($data, $response_type = 'json')
    {
        $this->response_type = $response_type;
        $this->data = $data;
    }

    public function response()
    {
        $data = $this->data;
        $response = new Response(['type' => $this->response_type]);
        $response->setData($data);
        return $response;
    }
}